{% extends "base.html" %}
{% load match %}
{% load pretty_user %}

{% block additional_title %}
Pregled meča
{% endblock %}

{% block content %}

<center>
	<h2>
	{% if match.game_type == 1 %}
	Pregled šahovskog meča
	{% elif match.game_type == 2 %}
	Pregled meča stonog fudbala
	{% elif match.game_type == 3 %}
	Pregled fudbalskog meča
	{% elif match.game_type == 4 %}
	Pregled basket meča
	{% else%}
	{% endif %}
	</h2>
	
	{% if perms.mdcsapp.delete_match %}
	<div style="float: right;">
		<a href="http://localhost:8000/mdcs/match/undo/{{ match.id }}/">
			Poništi meč <img width="16" height="16" title="Poništi meč" src="/mdcs/media/images/delete.png">
		</a>
	</div>
	{% endif %}
	
	<div class="result_big">
		{% if match.game_type == 1 and match.result == "0:0" %}
		½ : ½
		{% else %} 
		{{ match.result }}
		{% endif %}
	</div>
	{{ match|match:4 }}
	<div class="datetime_big">{{ match.date_played | date }} {{ match.date_played | time }}</div>

	<h2>Kretanje poena</h2>
	<img src="{{ image_url }}" alt="timeline"></img>
	
	<br/>
	<br/>
	<br/>
	<h2 id="comments">Komentari na meč</h2>

	{% for comment in match.matchcomment_set.all %}
		<div id="comment">
			<div class="commentPublished">
				{{ comment.comment_author|pretty_user }}
				{% if comment.date_updated %}
				<span class="commentTime">({{ comment.date_created|date }} {{ comment.date_created|time }}, izmenjen {{ comment.date_updated|date }} u {{ comment.date_updated|time }}):</span>
				{% else %}
				<span class="commentTime">({{ comment.date_created|date }} {{ comment.date_created|time }}):</span>
				{% endif %}
			{% if user.is_superuser %}
			<a href="/mdcs/match/{{ match.id }}/edit_comment/{{ comment.id }}/">
				<img src="/mdcs/media/images/edit.png" width="16" height="16" title="Izmeni komentar"/>
			</a>
			{% else %}
				{% if perms.mdcsapp.change_matchcomment %}
					{% ifequal user comment.user_created.user %}
						<a href="/mdcs/match/{{ match.id }}/edit_comment/{{ comment.id }}/">
							<img src="/mdcs/media/images/edit.png" width="16" height="16" title="Izmeni komentar"/>
						</a>
					{% endifequal %}
				{% endif %}
			{% endif %}
			</div>
			<div class="commentText">{{ comment.comment_text|safe }}</div>
		</div>
	{% endfor %}

	{% if perms.mdcsapp.add_matchcomment %}
	<br/>
	<a href="/mdcs/match/{{ match.id}}/add_comment/">Dodaj novi komentar</a>
	{% endif %}
</center>
{% endblock %}